#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QToolBar>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //菜单栏
    QMenuBar* menuBar = this->menuBar();

    //工具栏
    QToolBar* toolBar1 = new QToolBar("工具栏1");
    QToolBar* toolBar2 = new QToolBar("工具栏2");

    this->addToolBar(Qt::LeftToolBarArea,toolBar1);
    this->addToolBar(Qt::RightToolBarArea,toolBar2);
    toolBar2->setAllowedAreas(Qt::RightToolBarArea|Qt::TopToolBarArea);

    QAction* act1 = new QAction("功能1");
    QAction* act2 = new QAction("功能2");
    QAction* act3 = new QAction("功能3");
    QAction* act4 = new QAction("功能4");

    toolBar1->addAction(act1);
    toolBar1->addAction(act2);
    toolBar2->addAction(act3);
    toolBar2->addAction(act4);

    connect(act1,&QAction::triggered,this,&MainWindow::hanle1);
    connect(act2,&QAction::triggered,this,&MainWindow::hanle2);
    connect(act3,&QAction::triggered,this,&MainWindow::hanle3);
    connect(act4,&QAction::triggered,this,&MainWindow::hanle4);

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::hanle1()
{
    qDebug()<<"act1";
}
void MainWindow::hanle2()
{
    qDebug()<<"act2";
}
void MainWindow::hanle3()
{
    qDebug()<<"act3";
}
void MainWindow::hanle4()
{
    qDebug()<<"act4";
}

